/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HelpWindow.java
 *
 * Created on 12 Ιουλ 2010, 7:39:25 πμ
 */
package help;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import myComponents.myGUI.MyDraggable;
import tools.MySeriesLogger;
import tools.Skin;

/**
 *
 * @author ssoldatos
 */
public class HelpWindow extends MyDraggable {

  private static final long serialVersionUID = 1241234234L;
  public static final int ADMIN_SERIES = 0;
  public static final int ADMIN_EPISODES = 1;
  public static final int RECYCLE_BIN = 2;
  public static final int START_APPLICATION = 3;
  public static final int DOWNLOAD_TORRENT = 4;
  public static final int IMPORT_EPISODES = 5;
  public static final int GENERAL_OPTIONS = 6;
  public static final int INTERNET_OPTIONS = 7;
  public static final int RENAME_OPTIONS = 8;
  public static final int RENAMING = 9;
  public static final int APPEARANCE_OPTIONS = 10;
  public static final int PERFORMANCE_OPTIONS = 11;
  public static final int SUBTITLES_OPTIONS = 12;

  public HelpWindow(int page) {
    String url = null;

    MySeriesLogger.logger.log(Level.INFO, "Initializing components");
    initComponents();
    MySeriesLogger.logger.log(Level.FINE, "Components initialized");
    MySeriesLogger.logger.log(Level.INFO, "Setting page to {0}", page);
    switch (page) {
      case ADMIN_SERIES:
        label_title.setText("Series Administration");
        url = "series_administration";
        break;
      case ADMIN_EPISODES:
        label_title.setText("Episodes Administration");
        url = "episodes_administration";
        break;
      case RECYCLE_BIN:
        label_title.setText("Recycle Bin");
        url = "recycle_bin";
        break;
      case START_APPLICATION:
        label_title.setText("Start Application");
        url = "start_application";
        break;
      case DOWNLOAD_TORRENT:
        label_title.setText("Download Torrent");
        url = "download_torrent";
        break;
      case IMPORT_EPISODES:
        label_title.setText("Import Episodes");
        url = "import_episodes";
        break;
      case GENERAL_OPTIONS:
        label_title.setText("General Options");
        url = "general_options";
        break;
      case INTERNET_OPTIONS:
        label_title.setText("Internet Options");
        url = "internet_options";
        break;
      case RENAME_OPTIONS:
        label_title.setText("Renaming Options");
        url = "renaming_options";
        break;
      case RENAMING:
        label_title.setText("Renaming Episodes");
        url = "episodes_renaming";
        break;
      case APPEARANCE_OPTIONS:
        label_title.setText("Appearance Options");
        url = "appearance_options";
        break;
      case PERFORMANCE_OPTIONS:
        label_title.setText("Performance Options");
        url = "performance_options";
        break;
      case SUBTITLES_OPTIONS:
        label_title.setText("Subtitles Options");
        url = "subtitles_options";
        break;
    }
    java.net.URL helpURL = Help.class.getResource("/help/html/" + url + ".html");
    try {
      MySeriesLogger.logger.log(Level.INFO, "Setting content to url {0}", helpURL);
      content.setPage(helpURL);
      MySeriesLogger.logger.log(Level.FINE, "Content succesfuly set");
    } catch (IOException ex) {
      Logger.getLogger(HelpWindow.class.getName()).log(Level.SEVERE, null, ex);
    }
    content.setCaretPosition(0);
    setLocationRelativeTo(null);
    setVisible(true);
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    main_panel = new javax.swing.JPanel();
    inner_panel = new javax.swing.JScrollPane();
    content = new javax.swing.JEditorPane();
    myButton1 = new myComponents.myGUI.buttons.MyButtonCancel();
    label_title = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

    jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    main_panel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    inner_panel.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    inner_panel.setViewportView(content);

    javax.swing.GroupLayout main_panelLayout = new javax.swing.GroupLayout(main_panel);
    main_panel.setLayout(main_panelLayout);
    main_panelLayout.setHorizontalGroup(
      main_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(inner_panel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 828, Short.MAX_VALUE)
    );
    main_panelLayout.setVerticalGroup(
      main_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(inner_panel, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
    );

    myButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        myButton1ActionPerformed(evt);
      }
    });

    label_title.setFont(label_title.getFont().deriveFont(label_title.getFont().getStyle() | java.awt.Font.BOLD, label_title.getFont().getSize()+2));
    label_title.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label_title.setText("jLabel1");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel1Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel1Layout.createSequentialGroup()
            .addComponent(main_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGap(10, 10, 10))
          .addComponent(myButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addGroup(jPanel1Layout.createSequentialGroup()
            .addComponent(label_title, javax.swing.GroupLayout.PREFERRED_SIZE, 797, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())))
    );
    jPanel1Layout.setVerticalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel1Layout.createSequentialGroup()
        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
          .addComponent(myButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(label_title))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(main_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void myButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_myButton1ActionPerformed
    MySeriesLogger.logger.log(Level.INFO, "Closing window");
    dispose();
  }//GEN-LAST:event_myButton1ActionPerformed
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JEditorPane content;
  private javax.swing.JScrollPane inner_panel;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JLabel label_title;
  private javax.swing.JPanel main_panel;
  private myComponents.myGUI.buttons.MyButtonCancel myButton1;
  // End of variables declaration//GEN-END:variables
}
